package com.gitee.wsl.ext.number


/**
 * @returns null if [this] is equal to 0
 */
 fun Int?.takeIfNotZero(): Int? = takeIf { it != 0 }

/**
 * @returns null if [this] is equal to 0
 */
 fun Long?.takeIfNotZero(): Long? = takeIf { it != 0L }

/**
 * @returns null if [this] is equal to 0
 */
 fun Double?.takeIfNotZero(): Double? = takeIf { it != 0.0 }

/**
 * @returns null if [this] is equal to 0
 */
 fun Float?.takeIfNotZero(): Float? = takeIf { it != 0.0f }

/**
 * @returns null if [this] is equal to 0
 */
 fun Short?.takeIfNotZero(): Short? = takeIf { it != 0.toShort() }

/**
 * @returns null if [this] is equal to 0
 */
 fun Byte?.takeIfNotZero(): Byte? = takeIf { it != 0.toByte() }

/**
 * @returns null if [this] is NaN or Infinity
 */
 fun Double?.takeIfFinite(): Double? = this?.takeIf { it.isFinite() }

/**
 * @returns null if [this] is NaN or Infinity
 */
 fun Float?.takeIfFinite(): Float? = this?.takeIf { it.isFinite() }
